import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: "/home",
    component: () => import("@/views/index.vue")
  },
  {
    path: "/about",
    component: () => import("@/views/about.vue")
  },
  {
    path: "/pinia",
    component: () => import("@/views/pinia.vue")
  },
  {
    path: "/template",
    component: () => import("@/views/template.vue")
  },

];
export const router = createRouter({
  history: createWebHistory(),
  routes,
});


// import { createRouter, createWebHistory } from 'vue-router'
// import { useAuthStore } from '@/stores/useAuthStore'
// import HomeView from '@/views/HomeView.vue'
// import LoginView from '@/views/LoginView.vue'
// const router = createRouter({
//   history: createWebHistory(import.meta.env.BASE_URL),
//   routes: [{ path: '/', redirect: '/login', },
//   { path: '/home', name: 'home', component: HomeView, },
//   { path: '/login', name: 'login', component: LoginView, },]
//   ,
// })
// // 路由守卫
// router.beforeEach((to, from, next) => {
//   const authStore = useAuthStore()
//   if (to.name != 'login' && authStore.isLogin == false) { next('/login') } else { next() }
// })
// export default router